package com.hjj.services;

import com.hjj.exception.MyLengthException;
import org.springframework.stereotype.Service;

@Service
public class DemoServicesImp implements DemoServices{

    @Override
    public float add(float opt1, float opt2) throws MyLengthException {
        if (opt1 > 1000 || opt1 < 1 || opt2 > 1000 || opt2 < 1) throw new MyLengthException("操作数超标了");
        return opt1 + opt2;
    }

    @Override
    public float sub(float opt1, float opt2) {
        return opt1 - opt2;
    }

    @Override
    public float mul(float opt1, float opt2) {
        return opt1 * opt2;
    }

    @Override
    public float div(float opt1, float opt2) {
        return opt1 / opt2;
    }
}
